package com.zork.data.generator.controller;

import com.zork.data.generator.model.DataMap;
import com.zork.data.generator.service.DataMapService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author xiesen
 */
@RestController
@Slf4j
@RequestMapping("/map")
public class DataMapController {
    @Resource
    DataMapService dataMapService;

    @RequestMapping("/add")
    public String addUser(@RequestBody DataMap dataMap) {
        log.info("dataMap: {}", dataMap);
        final int i = dataMapService.addDataMap(dataMap);
        if (i > 0) {
            log.info("插入成功");
            return "success";
        }
        log.info("插入失败");
        return "fail";
    }

    @GetMapping("/sync")
    public int syncDataMap() {
        return dataMapService.syncDataMap();
    }
}
